# 创建 序列化器
from rest_framework import serializers

from tushu.models import BookModel

class BookSerializer(serializers.ModelSerializer):
    class Meta:
        #  1. 告诉 序列化器--对应哪个模型类
        model = BookModel
        #  2. 告诉 序列化器-- 对哪些字段
        fields ='__all__'
        # fields = ('btitle', 'price')
        # exclude = ('price',)
        read_only_fields = ('bread',)
        extra_kwargs = {
            'price':{'min_value':0}
        }

